package com.wisezone.workflow.dao.ibatis;

import java.util.List;

import com.wisezone.common.dao.impl.BaseDaoImpl;
import com.wisezone.workflow.bean.WfActivity;
import com.wisezone.workflow.bean.search.WfActivitySearch;
import com.wisezone.workflow.dao.WfActivityDao;
import com.wisezone.workflow.exception.WfDaoException;

/**
 * IBATIS 活动实现类
 * @author tss 2009-09-05
 * 
 */
public class WfActivityDaoImpl extends BaseDaoImpl implements WfActivityDao{

	
    public WfActivityDaoImpl() {
        super();
    }
    
    /**
     * 获得中间活动列表
     * @param processDefId
     * @return
     * @throws WfDaoException
     */
    public List<WfActivity> getMiddleList(Long processDefId) throws WfDaoException{
    	
		WfActivitySearch searchEntity = new WfActivitySearch();
		searchEntity.setProcessDefId(processDefId);
		searchEntity.addSqlClause(" category != 9 and category != 10 ");
		return this.listAll(searchEntity);
    }
    
    /**
     * 获得非开始活动列表
     * @param processDefId
     * @return
     * @throws WfDaoException
     */
    public List<WfActivity> getNotStartList(Long processDefId) throws WfDaoException{
    	
    	WfActivitySearch searchEntity = new WfActivitySearch();
    	searchEntity.setProcessDefId(processDefId);
    	searchEntity.addSqlClause(" category != 9 ");
    	return this.listAll(searchEntity);
    }

   /**
    * 根据活动Id 获得下一活动
    */
   public WfActivity getNextActivity(Long aid) throws WfDaoException{
	   
    	return this.get("selectNextActivity", aid);
    }

   /**
    * 根据活动id 和下一活动名称活动下一活动
    * @param aid
    * @param name
    * @return
    * @throws WfDaoException
    */
   public WfActivity getNextActivity(Long aid,String name) throws WfDaoException{
	   
	   WfActivity activity = new WfActivity();
	   activity.setId(aid);
	   activity.setName(name);
	   return this.get("selectNextActivity", activity);
   }
   
	/**
	 * 根据流程模板Id删除
	 * @param id
	 * @throws WfDaoException
	 */
   public void deleteByProcessDefId(Long id) throws WfDaoException{
     	this.execute("deleteByProcessDef",id);
   }	






    
  
  

   
}